<template>
  <view class="userPage">
    <view class="user-header" :style="'margin-top:' + 140 + 'rpx'">
      <view class="header-img" @click="toLogin">
        <image src="../../static/logo.png" mode=""></image>
      </view>
      <view class="header-name">微信名称{{capsuleHeight}}</view>
      <view class="header-notice" @click="toSystemInfo">
        <image src="../../static/icon/user/notice.png" mode=""></image>
      </view>
      <view class="header-set" @click="toSet">
        <image src="../../static/icon/user/set.png" mode=""></image>
      </view>
    </view> 
    <view class="user-container">
      <view class="container-top">
        <view class="container-title">我的订单</view>
        <view class="container-label" @click="toCommodity(0)">查看全部
          <up-icon name="arrow-right" color="#999999" size="24rpx"></up-icon>
        </view>
      </view>
      <view class="container-list">
        <view class="container-nav" v-for="(item,index) in containerList" :key="index" @click="toCommodity(item.type)">
          <image :src="item.img" mode=""></image>
          <view class="container-text">{{item.name}}</view>
        </view>
      </view>
    </view>
    <view class="user-box">
      <view class="box-left" @click="toCreation">
        我的作品
        <view class="box-btn">去查看</view>
      </view>
      <view class="box-right">
        <view class="box-top">我的收藏</view>
        <view class="box-bottom">我的关注</view>
      </view>
    </view>
    <view class="user-serve">
      <view class="serve-title">服务</view>
      <view class="serve-list">
        <view class="serve-nav" v-for="(item,index) in serveList" :key="index">
          <image :src="item.img" mode=""></image>
          <view class="serve-name">{{item.name}}</view>
          <up-icon name="arrow-right" color="#999999" size="24rpx"></up-icon>
        </view>
      </view>
    </view>
  </view>
  <tab-popup :show.sync="show" @showClose="onShowClose"></tab-popup>
  <tab-bar currentSelect="user" @showBottom="onShowBottom"></tab-bar>
</template>

<script setup>
  import {
    ref,
    onMounted,
    reactive
  } from 'vue'
  const show = ref(false)
  let capsuleHeight = ref('')
  const containerList = reactive([{
    img: '/static/icon/user/wait-payment.png',
    name: "待付款",
    type: 1
  }, {
    img: '/static/icon/user/wait-delivery.png',
    name: "待发货",
    type: 2
  }, {
    img: '/static/icon/user/wait-harvest.png',
    name: "待收货",
    type: 3
  }, {
    img: '/static/icon/user/complete.png',
    name: "已完成",
    type: 4
  }])
  const serveList = reactive([{
    img: '/static/icon/user/notepad.png',
    name: "收货地址",
    type: 1
  }, {
    img: '/static/icon/user/contact.png',
    name: "联系客服",
    type: 2
  }])
  onMounted(() => {
    const sysInfo = wx.getSystemInfoSync();
    capsuleHeight = (sysInfo.statusBarHeight + 32) + sysInfo.safeArea.top;
  })
  function toCommodity(type){
    console.log(type);
    uni.navigateTo({
      url:`/subpages/userPage/commodity-order?type=${type}`
    })
  }
  function toLogin(){
    uni.navigateTo({
      url:'/pages/loginPage/index'
    })
  }
  function toSystemInfo(){
    uni.navigateTo({
      url:'/subpages/userPage/system-info'
    })
  }
  function toSet(){
    uni.navigateTo({
      url:'/subpages/userPage/user-set'
    })
  }
  function toCreation(){
    uni.navigateTo({
      url:'/subpages/userPage/user-creation'
    })
  }
  function onShowBottom(val) {
    show.value = val
  }

  function onShowClose(val) {
    show.value = val
  }
</script>

<style lang="less">
  .userPage {
    display: flex;
    box-sizing: border-box;
    padding: 0 32rpx;
    flex-direction: column;
    align-items: center;

    .user-header {
      height: 122rpx;
      width: 100%;
      display: flex;
      align-items: center;
      box-sizing: border-box;

      .header-img {
        width: 100rpx;
        height: 100rpx;
        border-radius: 50rpx;
        border: 2rpx solid rgba(255, 255, 255, 1);

        image {
          width: 100rpx;
          height: 100rpx;
          border-radius: 50rpx;
        }
      }

      .header-name {
        flex: 1;
        margin-left: 20rpx;
        font-size: 44rpx;
        font-weight: 500;
        color: rgba(51, 51, 51, 1);
      }

      .header-notice {
        width: 48rpx;
        height: 48rpx;
        margin-left: 32rpx;

        image {
          width: 48rpx;
          height: 48rpx;
        }
      }

      .header-set {
        width: 48rpx;
        height: 48rpx;
        margin-left: 32rpx;

        image {
          width: 48rpx;
          height: 48rpx;
        }
      }
    }

    .user-container {
      width: 100%;
      height: 250rpx;
      border-radius: 24rpx;
      background: rgba(255, 255, 255, 1);
      margin-top: 40rpx;
      display: flex;
      flex-direction: column;
      box-sizing: border-box;
      padding: 32rpx;

      .container-top {
        display: flex;
        justify-content: space-between;

        .container-title {
          font-size: 32rpx;
          font-weight: 500;
          color: rgba(51, 51, 51, 1);
        }

        .container-label {
          display: flex;
          font-size: 24rpx;
          font-weight: 400;
          color: rgba(153, 153, 153, 1);
          align-items: center;
        }
      }

      .container-list {
        flex: 1;
        display: flex;
        align-items: flex-end;
        justify-content: space-around;

        .container-nav {
          display: flex;
          flex-direction: column;
          align-items: center;

          image {
            height: 64rpx;
            width: 64rpx;
          }

          .container-text {
            font-size: 26rpx;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            margin-top: 12rpx;
          }
        }
      }
    }

    .user-box {
      height: 280rpx;
      width: 100%;
      margin-top: 20rpx;
      display: flex;
      font-size: 32rpx;
      font-weight: 500;
      color: rgba(51, 51, 51, 1);

      .box-left {
        position: relative;
        width: 50%;
        height: 280rpx;
        border-radius: 24rpx;
        background-color: #fff;
        box-sizing: border-box;
        padding: 24rpx 32rpx;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        overflow: hidden;

        .box-btn {
          width: 136rpx;
          height: 64rpx;
          border-radius: 32rpx;
          background-color: #FF416C;
          font-size: 24rpx;
          font-weight: 400;
          line-height: 64rpx;
          text-align: center;
          color: rgba(255, 255, 255, 1);
          z-index: 1;
        }
      }

      .box-left::before {
        content: '';
        position: absolute;
        right: -60rpx;
        bottom: -56rpx;
        width: 224rpx;
        height: 224rpx;
        border-radius: 50%;
        background-color: #ccc;
        z-index: 0;
      }

      .box-right {
        width: 50%;
        margin-left: 24rpx;
        display: flex;
        flex-direction: column;

        .box-top {
          position: relative;
          width: 100%;
          height: 128rpx;
          border-radius: 24rpx;
          background-color: #fff;
          box-sizing: border-box;
          padding: 0 32rpx;
          display: flex;
          align-items: center;
          overflow: hidden;
        }

        .box-top::after {
          content: '';
          position: absolute;
          width: 120rpx;
          height: 120rpx;
          right: -8rpx;
          bottom: -24rpx;
          background: url("https://geiqiutiyu.oss-cn-hangzhou.aliyuncs.com/uploads/20240826/1275eb5b8f0f7c82ecd8cccdba820028.png") no-repeat;
          background-size: cover;
          z-index: 1;
        }

        .box-top::before {
          content: '';
          position: absolute;
          width: 73rpx;
          height: 63rpx;
          right: 14rpx;
          bottom: 4rpx;
          background: url("https://geiqiutiyu.oss-cn-hangzhou.aliyuncs.com/uploads/20240826/745120f3a101fa95ae47a51dadc618cd.png") no-repeat;
          background-size: cover;
          z-index: 2;
        }

        .box-bottom {
          position: relative;
          width: 100%;
          height: 128rpx;
          margin-top: 24rpx;
          border-radius: 24rpx;
          background-color: #fff;
          box-sizing: border-box;
          padding: 0 32rpx;
          display: flex;
          align-items: center;
          overflow: hidden;
        }

        .box-bottom::after {
          content: '';
          position: absolute;
          width: 120rpx;
          height: 120rpx;
          right: -8rpx;
          bottom: -24rpx;
          background: url("https://geiqiutiyu.oss-cn-hangzhou.aliyuncs.com/uploads/20240826/174589a4b7b1fb6f2852d9de6c1e683b.png") no-repeat;
          background-size: cover;
          z-index: 1;
        }

        .box-bottom::before {
          content: '';
          position: absolute;
          width: 73rpx;
          height: 63rpx;
          right: 16rpx;
          bottom: 8rpx;
          background: url("https://geiqiutiyu.oss-cn-hangzhou.aliyuncs.com/uploads/20240826/07b97a1a8954efebda6c055ccd4fcc59.png") no-repeat;
          background-size: cover;
          z-index: 2;
        }
      }
    }

    .user-serve {
      width: 100%;
      height: 328rpx;
      border-radius: 24rpx;
      background: #FFFFFF;
      margin-top: 20rpx;
      box-sizing: border-box;
      padding: 0 32rpx;

      .serve-title {
        height: 104rpx;
        width: 100%;
        display: flex;
        align-items: center;
        font-size: 32rpx;
        font-weight: 500;
        color: rgba(51, 51, 51, 1);
      }

      .serve-list {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;

        .serve-nav {
          display: flex;
          align-items: center;
          width: 100%;
          height: 112rpx;

          image {
            height: 48rpx;
            width: 48rpx;
          }

          .serve-name {
            flex: 1;
            font-size: 30rpx;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            margin-left: 20rpx;
          }
        }
      }
    }
  }
</style>